clear all
set more off 

********************************************************************************
* main migration event studies shown in figure 4

********************************************************************************

* near-near

use  mig_analysis_file_201458_250, clear

reghdfe log_inc tx_n3 tx_n2 tx_n1 zero tx_1 tx_2 tx_3  /// 
	if origin_student<.2 & inrange(move_year,2011,2017)>0 & building_sample==1 & min_number>0  ///
	[aweight=building_sample_weight],absorb(msa_year building_id) vce(cl building_id)
estimates store log_inc
	
reghdfe vlow_inc tx_n3 tx_n2 tx_n1 zero tx_1 tx_2 tx_3  /// 
	if origin_student<.2 & inrange(move_year,2011,2017)>0 & building_sample==1 & min_number>0  ///
	[aweight=building_sample_weight],absorb(msa_year building_id) vce(cl building_id)
estimates store vlow_inc


coefplot (vlow_inc,msymbol(Sh) mcolor(navy) lcolor(navy) ciopts(lcolor(navy)) recast(connected) offset(-0.05) ) ///
	(log_inc, msymbol(D) mcolor(maroon) lcolor(maroon) ciopts(lcolor(maroon)) recast(connected) offset(0.05)), ///
	keep(tx* zero) ///			
	vert ///
	yline(0,lcolor(black) lpattern(dash) lwidth(0.2)) xtitle(Years to treatment) ///
	rename(tx_n3 = "-3" tx_n2 = "-2" tx_n1 = "-1" zero="0" tx_1 = "1" tx_2 = "2" tx_3 = "3" )  ///
	ytitle("Event Study Coefficient") graphregion(color(white)) bgcolor(white) msymbol(O D) ///
	omitted legend(label(2 "Below 2/3 Median Income") label(4 "Log(origin income)")) ///
	yscale(range(-.12 .12)) ytick(-.1 (.025) .1) ylabel(-.1(.05) .1)
	
	
}

* near far 
use mig_analysis_file_20145_all, clear

reghdfe log_inc tx_n3 tx_n2 tx_n1 zero tx_1 tx_2 tx_3 /// 
	if origin_student<.2 & inrange(move_year,2011,2017)>0 &  building_sample==1 ///
	&  tx250_min_number>0 & tx256_min_number>0 ///
	[aweight=building_sample_weight] ,absorb(ring_fe building_id_year) vce(cl building_id)
estimates store log_inc


reghdfe vlow_inc tx_n3 tx_n2 tx_n1 zero tx_1 tx_2 tx_3 /// 
	if origin_student<.2 & inrange(move_year,2011,2017)>0 &  building_sample==1 ///
	&  tx250_min_number>0 & tx256_min_number>0 ///
	[aweight=building_sample_weight] ,absorb(ring_fe building_id_year) vce(cl building_id)
estimates store vlow_inc
	
	

coefplot (vlow_inc,msymbol(Sh) mcolor(navy) lcolor(navy) ciopts(lcolor(navy)) recast(connected) offset(-0.05) ) ///
	(log_inc, msymbol(D) mcolor(maroon) lcolor(maroon) ciopts(lcolor(maroon)) recast(connected) offset(0.05)), ///
	keep(tx* zero) ///			
	vert ///
	yline(0,lcolor(black) lpattern(dash) lwidth(0.2)) xtitle(Years to treatment) ///
	rename(tx_n3 = "-3" tx_n2 = "-2" tx_n1 = "-1" zero="0" tx_1 = "1" tx_2 = "2" tx_3 = "3" tx_4="4")  ///
	ytitle("Event Study Coefficient") graphregion(color(white)) bgcolor(white) msymbol(O D) ///
	omitted legend(label(2 "Below 2/3 Median Income") label(4 "Log(Origin Income)")) ///
	yscale(range(-.05 .05)) ytick(-.05 (.025) .05) ylabel(-.05 (.025) .05)


